﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NexTrackDesktop.Media;
using NexTrackDesktop.NexTrack;
using System.Windows;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Microsoft.Win32;
using NexTrackDesktop.ViewModels;
using NexTrackDesktop.MainService;


    /// <summary>
    /// This class stores guest list information and links to GuestTab.
    /// </summary>
    public class GuestsViewModel : DependencyObject
    {
        public ObservableCollection<UserViewModel> Invited { get; private set; }
        public ObservableCollection<UserViewModel> Requested { get; private set; }
        public ObservableCollection<UserViewModel> Friends { get; private set; }

        public ICommand InvitedAddedCommand { get; private set; }
        public ICommand RequestedAllowedCommand { get; private set; }
        public ICommand RequestedDeniedCommand { get; private set; }
        public ICommand FriendsAddedCommand { get; private set; }
        
        /// <summary>
        /// This method creates a new GuestsViewModel.
        /// </summary>
        public GuestsViewModel()
        {
            Invited = new ObservableCollection<UserViewModel>();
            Requested = new ObservableCollection<UserViewModel>();
            Friends = new ObservableCollection<UserViewModel>();

            createCommands();
        }

        /// <summary>
        /// This method creates commands that are linked to GuestTab view.
        /// </summary>
        void createCommands()
        {
            //TODO
        }

        /// <summary>
        /// This method adds the specified user to the invited list.
        /// </summary>
        /// <param name="user">User to be invited</param>
        void InvitedAdded(User user)
        {
            Invited.Add(new UserViewModel(user));
        }

        /// <summary>
        /// This method adds a requested user to the invited list.
        /// </summary>
        /// <param name="user">User to allow</param>
        void RequestedAllowed(User user)
        {
            UserViewModel tempUser = new UserViewModel(user);
            Requested.Remove(tempUser);
            Invited.Add(tempUser);
        }

        /// <summary>
        /// This method denies a requested user.
        /// </summary>
        /// <param name="user">User to deny</param>
        void RequestedDenied(User user)
        {
            UserViewModel tempUser = new UserViewModel(user);
            Requested.Remove(tempUser);
        }

        /// <summary>
        /// This method adds a user to the invited list.
        /// </summary>
        /// <param name="user">User to invite</param>
        void FriendsAdded(User user)
        {
            Friends.Add(new UserViewModel(user));
        }
    }